home *** CD-ROM | disk | FTP | other *** search
- /*
- File: TTaskSchedulerExample.h
-
- Contains: Declaraton for TArcTAsk, a TOperation subclass. TOperation objects
- contain the implementation of the task to be performed. This operation
- is placed on a TTaskScheduler to be performed at each SystemTask time.
- TArcTask performs a drawing of an arc, from an angle 0 to 360 degrees.
-
- Copyright: © 1993 by Apple Computer, Inc., all rights reserved.
-
- */
-
- #ifndef __TTASKSCHEDULEREXAMPLE__
- #define __TTASKSCHEDULEREXAMPLE__
-
- #ifndef __DIALOGS__
- #include <Dialogs.h>
- #endif
-
- #ifndef __FONTS__
- #include <Fonts.h>
- #endif
-
- #ifndef __MEMORY__
- #include <memory.h>
- #endif
-
- #ifndef __QUICKDRAW__
- #include <QuickDraw.h>
- #endif
-
- #ifndef __RESOURCES__
- #include <Resources.h>
- #endif
-
- #ifndef __TOOLUTILS__
- #include <ToolUtils.h>
- #endif
-
- #ifndef __WINDOWS__
- #include <Windows.h>
- #endif
-
- ///————————————————————————————————————————————————————————————————————————————————————
- /// TArcTask
- ///————————————————————————————————————————————————————————————————————————————————————
-
- class TArcTask : public TOperation {
- public:
- TArcTask(WindowPtr, short arcAngle);// Constructor
- virtual ~TArcTask(); // Destructor
- virtual void Process(); // Override
-
- private:
- WindowPtr fWindow; // pointer to our window record
- short fArcAngle; // the actual arc angle
- };
-
- ///————————————————————————————————————————————————————————————————————————————————————
- /// TArcTask IMPLEMENTATION
- ///————————————————————————————————————————————————————————————————————————————————————
-
- TArcTask::TArcTask(WindowPtr theWindow, short arcAngle )
- {
- fWindow = theWindow;
- fArcAngle = arcAngle % 360;
- }
-
- TArcTask::~TArcTask()
- {
- }
-
- void TArcTask::Process()
- {
- // draw the arc for this process
- GrafPtr oldport;
- GetPort( &oldport );
- SetPort( fWindow );
- ShowWindow( fWindow );
- if (fArcAngle == 0)
- EraseRect( &fWindow->portRect );
- PaintArc( &fWindow->portRect, 0, fArcAngle );
- SetPort( oldport );
-
- // delay .01 seconds so we don't do things too fast
- TStopwatch stopwatch;
- while( stopwatch.ElapsedMilliseconds() < 10 );
-
- delete this; // we are done
- }
-
- #endif
-